package com.major.javaweb;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("*.action")
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.addHeader("content-type","text/html;charset=utf-8");

        if ("zhangsan" == req.getSession().getAttribute("user")){
            resp.getWriter().write("登陆成功："+req.getSession().getAttribute("user"));
        }else {
            resp.getWriter().write("请先登录");
        }
        resp.getWriter().flush();
        resp.getWriter().close();
    }
}
